package com.erp.Util;

import com.erp.comm.TreeNode;

import java.sql.Array;
import java.util.ArrayList;
import java.util.List;

//节点层级关系构建
public class TreeNodeBuilder {


    public static List<TreeNode> Builder(List<TreeNode> nodes,Integer topId) {
        System.out.println(nodes.size()+"AAAAAAAAAAAAAAAAAA");
        List<TreeNode> list = new ArrayList<TreeNode>();
        for (TreeNode node1 :nodes){
            if (node1.getPid()==topId){
                list.add(node1);
            }
            for (TreeNode node2:nodes){
                if (node1.getId()==node2.getPid()){
                    node1.getChildren().add(node2);
                }
            }

        }
        return  list;

    }
}
